from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Course
from tools.observe_course import course_subject

@receiver(post_save, sender=Course)
def course_update_handler(sender, instance, created, **kwargs):
    """课程更新信号处理器"""
    if not created and instance.status == 'published':
        # 通知所有观察者课程已更新
        course_subject.notify(instance)